import os
import time
from multiprocessing import Queue, Process


def producer(q):
    for i in range(100):
        q.put(i)
        print(f"producer put data: {i}")
        time.sleep(1)

def consumer(q):
    while True:
        try:
            item = q.get()
            print(f"consumer get data :{item}")
        except Exception as e:
            print("consumer has error")
            continue

if __name__ == "__main__":
    q = Queue()
    p_pro = Process(target=producer,args=(q,))
    p_con = Process(target=consumer,args=(q,))

    p_pro.start()
    p_con.start()

    p_pro.join()
    p_con.join()